#ifndef TCPCLIENT_H
#define TCPCLIENT_H
#include <QMutex>
#include <QObject>
#include <QTcpSocket>
#include "protocol.h"
#include <QFile>
#include <QList>
#include <QPair>
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonDocument>
#include <QVariant>
#include <QMap>
class TcpClient : public QObject
{
    Q_OBJECT
public:
    explicit TcpClient(QObject *parent = nullptr);

    static TcpClient* get_instance();

    QString getUserName();

    void SetUserName(QString UserName);

    int InitFormConfig(QString FileName=":/Client.config");

    QTcpSocket& getUserTcp();

    QString GetUserName();

    bool Do_Connect();
public slots:

    void SendMsg(myuint Type,QJsonObject Info);

    void TcpConnectStatus();

    void RecvMsg();

    //void SendAddFriendRespondMsg(QString TagUser,long long Status);

signals:
    void sigConnectSuccess();

    void sigConnectFail(QString cuase);

private slots:

private:
    QString UserName;

    QString ServerIp;

    static TcpClient * m_TcpClient;

    static QMutex TcpClientMutex;

    quint16 ServerPort;

    QTcpSocket m_TcpSocket;

    static void destroy_instance();

};

#endif // TCPCLIENT_H
